package Google_Code_Jam;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

/*
 * @Author Josh Lear
 * @Date 4-12-2014
 * @Problem Bipartite Matching for 2 metrics.
 * round 1
 */
public class Google_Code_Jam_D {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int cases = sc.nextInt();
        for (int i = 1; i <= cases; i++) {
            int blocks = sc.nextInt();
            ArrayList<Double> naomiDeceitList = new ArrayList<Double>(1002);
            ArrayList<Double> kenDeceitList = new ArrayList<Double>(1002);
            ArrayList<Double> naomiList = new ArrayList<Double>(1002);
            ArrayList<Double> kenList = new ArrayList<Double>(1002);
            for (int j = 0; j < blocks; j++) {
                double cur = sc.nextDouble();
                naomiDeceitList.add(cur);
                naomiList.add(cur);
            }
            for (int j = 0; j < blocks; j++) {
                double cur = sc.nextDouble();
                kenDeceitList.add(cur);
                kenList.add(cur);
            }
            Collections.sort(kenDeceitList);
            Collections.sort(naomiDeceitList);
            Collections.sort(naomiList);
            Collections.sort(kenList);
            int nDeceit = 0;
            int nLegit = 0;
            int counter = blocks;
            for (int j = 0; j < blocks; j++) {
                counter--;
                double kLegitBig = kenList.get(counter);
                double kDeceitBig = kenDeceitList.get(counter);
                double nDeceitBig = naomiDeceitList.get(counter);
                double nLegitBig = naomiList.get(counter);
                if (nDeceitBig > kDeceitBig) {
                    nDeceit++;
                    naomiDeceitList.remove((Collections.binarySearch(
                            naomiDeceitList, kDeceitBig) + 1) * -1);
                    kenDeceitList.remove(counter);
                } else {
                    kenDeceitList.remove(counter);
                    naomiDeceitList.remove(0);
                }
                if (nLegitBig > kLegitBig) {
                    nLegit++;
                    kenList.remove(0);
                    naomiList.remove(counter);
                } else {
                    kenList.remove((Collections
                            .binarySearch(kenList, nLegitBig) + 1) * -1);
                    naomiList.remove(counter);
                }

            }
            System.out.println("Case #" + i + ": " + nDeceit + " " + nLegit);
        }
        sc.close();
    }

}
